-- @Author: 作者QQ381990860
-- @Date:   2021-10-30 19:45:05
-- @Last Modified by:   作者QQ381990860
-- @Last Modified time: 2022-09-02 15:32:36
--======================================================================--
-- @作者: QQ381990860
-- @创建时间:   2019-12-03 02:17:19
-- @Last Modified time: 2021-02-01 16:16:44
--======================================================================--
local 场景类_奇经神脉 = class(窗口逻辑)

local floor = math.floor
local format = string.format
local insert = table.insert
local remove = table.remove
local type = type
local mouseb = 引擎.鼠标弹起
local zts,zts1,tp

local function ms(mx)
	if mx == "飞燕女" then
		return 0x3F40F51A
	elseif mx == "英女侠" then
		return 0x8CE4F5B1
	elseif mx == "巫蛮儿" then
		return 0x7E5A0478
	elseif mx == "偃无师" then
		return 0xB74762FF
	elseif mx == "逍遥生" then
		return 0x2B092186
	elseif mx == "剑侠客" then
		return 0x75F646A9
	elseif mx == "骨精灵" then
		return 0xD26C8968
	elseif mx == "狐美人" then
		return 0x8B625417
	elseif mx == "鬼潇潇" then
		return 0xD70CBA7A
	elseif mx == "杀破狼" then
		return 0x9BF7DC7E
	elseif mx == "巨魔王" then
		return 0xB5F4F713
	elseif mx == "虎头怪" then
		return 0x4BC65441
	elseif mx == "舞天姬" then
		return 0x976BDFDB
	elseif mx == "玄彩娥" then
		return 0x62D522B6
	elseif mx == "桃夭夭" then
		return 0x4F9DF47A
	elseif mx == "羽灵神" then
		return 0x0CE5E05F
	elseif mx == "神天兵" then
		return 0x2F359481
	elseif mx == "龙太子" then
		return 0x784828C1
	end
end

local function sk(mp)
  if mp == "方寸山" then
    return {"魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池"}
  elseif mp == "女儿村" then
    return {"魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池"}
  elseif mp == "神木林" then
    return {"魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池"}
  elseif mp == "化生寺" then
    return {"魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池"}
  elseif mp == "大唐官府" then
    return {"魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池"}
  elseif mp == "阴曹地府" then
    return {"魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池"}
  elseif mp == "盘丝洞" then
    return {"魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池"}
  elseif mp == "无底洞" then
    return {"魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池"}
  elseif mp == "魔王寨" then
    return {"魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池"}
  elseif mp == "狮驼岭" then
    return {"魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池"}
  elseif mp == "天宫" then
    return {"魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池"}
  elseif mp == "普陀山" then
    return {"魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池"}
  elseif mp == "凌波城" then
    return {"魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池"}
  elseif mp == "五庄观" then
    return {"魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池"}
  elseif mp == "龙宫" then
    return {"魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池"}
      elseif mp == "花果山" then
    return {"魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池"}
      elseif mp == "女魃墓" then
    return {"魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池"}
      elseif mp == "天机城" then
    return {"魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池"}
      elseif mp == "梦幻西游" then
    return {"魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池","魂池"}

  end
end

local function ew(mp)
	if mp == "方寸山" then
		return "学习“顺势而为”以后，每个额外的乾元丹会：增加30点速度。学习“钟馗论道”以后，每个额外的乾元丹会：增加40点法术伤害。"
	elseif mp == "女儿村" then
	    return "学习“碎玉弄影”以后，每个额外丹会增加40点封印命中等级，学习“鸿渐于陆”以后，每个额外的乾元丹会增加80点抵抗封等级。"
   elseif mp == "神木林" then
		return "学习“风卷残云”以后乾元，每个额外的乾元丹会：增加40点法术伤害。学习“凋零之歌”以后，每个额外的乾元丹会：增加280点气血。"
	elseif mp == "化生寺" then
		return "学习“渡劫金身”以后，每个额外能力的乾元丹会增加30点治疗能力，学习“诸天看护”以后，每个额外的乾元丹会增加80点法术防御。"
	elseif mp == "大唐官府" then
		return "学习“无敌”以后，每个额外的乾元丹会增加40点伤害，学习“破军”以后，每个额外的乾元丹会增加280点气血。"
	elseif mp == "阴曹地府" then
		return "学习“魑魅缠身”以后，每个额外的乾元丹会：增加30点速度。学习“夜之王者”以后，每个额外的乾元丹会：增加40点伤害。"
	elseif mp == "盘丝洞" then
		return "学习“落花成泥”以后，每个额外的乾元丹会：增加80点法术防御。学习“偷龙转凤”以后，每个额外的乾元丹会：增加80点抵抗封印等级。"
	elseif mp == "无底洞" then
		return "学习“同舟共济”以后，每个额外的乾元丹会：增加80点法术防御。学习“妖风四起”以后，每个额外的乾元丹会：增加40点封印命中等级。"
	elseif mp == "魔王寨" then
		return "学习“魔焰滔天”以后，每个额外的乾元丹会：增加40点法术伤害。学习“烈焰真诀”以后，每个额外的乾元丹会：增加80点防御。"
	elseif mp == "狮驼岭" then
		return "学习“背水一战”以后，每个额外的乾元丹会：增加30点速度。学习“肝胆相照”以后，每个额外的乾元丹会：增加80点防御。"
	elseif mp == "天宫" then
		return "学习“画地为牢”以后，每个额外的乾元丹会：增加40点封印命中等级。学习“风雷韵动”以后，每个额外的乾元丹会：增加40点法术伤害。"
	elseif mp == "普陀山" then
		return "学习“波澜不惊”以后，每个额外的乾元丹会：增加30点治疗能力。学习“五行制化”以后，每个额外的乾元丹会：增加30点速度。"
	elseif mp == "凌波城" then
		return "学习“无敌”以后，每个额外的乾元丹会增加40点伤害，学习“破军”以后，每个额外的乾元丹会增加280点气血。"
	elseif mp == "五庄观" then
		return "学习“清风望月”以后，每个额外的乾元丹会：增加30点速度。学习“天命剑法”以后，每个额外的乾元丹会：增加40点伤害。"
	elseif mp == "龙宫" then
		return "学习“亢龙归海”以后，每个额外的乾元丹会：增加40点法术伤害。学习“雷浪穿云”以后，每个额外的乾元丹会：增加80点防御。"
	elseif mp == "天机城" then
        return "学习“亢龙归海”后,每个额外的乾元丹可以使你:增加280点气血。学习“所向披靡”后,每个额外得乾元丹可以使你:增加40点伤害。"
    elseif mp == "花果山" then
        return "学习“战神出世”后,每个额外的乾元丹可以使你:增加30点速度。学习“齐天神通”后,每个额外得乾元丹可以使你:增加40点伤害。"
    elseif mp == "女魃墓" then
        return "学习“觉醒”后,每个额外的乾元丹可以使你:增加30点速度。学习“无相诛戮”后,每个额外的乾元丹可以是你:增加40点法术伤害。"
	end
end
function 场景类_奇经神脉:初始化(根)
	self.ID = 33
	self.x = 90+(全局游戏宽度-800)/2
	self.y = 77
	self.xx = 0
	self.yy = 0
	self.注释 = "奇经神脉"
	self.可视 = false
	tp = 根

	self.焦点 = false
	self.可移动 = true
	local 资源 = 根.资源
	local 按钮 = 根._按钮
	local 自适应 = 根._自适应
	-- self.资源组 = {
	-- 	[1] = 自适应.创建(99,1,630,467,3,9),
	-- 	[2] = 按钮.创建(自适应.创建(104,4,16,16,4,3),0,0,4,true,true),
	-- 	[3] = 按钮.创建(自适应.创建(103,4,72,22,1,3),0,0,4,true,true,"确认加点"),
	-- 	[4] = 按钮.创建(自适应.创建(103,4,55,22,1,3),0,0,4,true,true,"取消"),
	-- 	[5] = 按钮.创建(自适应.创建(103,4,72,22,1,3),0,0,4,true,true,"重置魂池"),
	-- 	[6] = {},
	-- 	[7] = 资源:载入('JM.dll',"网易WDF动画",0x22D22D6D),
	-- 	[8] = 自适应.创建(5,1,600,419,3,9),
	-- 	[9] = 资源:载入('JM.dll',"网易WDF动画",0xECEDD9A8).精灵,

	-- }
	-- self.资源组[9]:置区域(0,0,2,395)
	-- for n=2,5 do
	--     self.资源组[n]:绑定窗口_(33)
	-- end
	-- for i=1,21 do
	-- 	self.资源组[6][i] = 根._技能格子(0,0,n,"奇经神脉")
	-- end
	self.选中 = nil

	zts = tp.字体表.华康字体
	zts1 = tp.字体表.华康字体
	self.窗口时间 = 0
	self.魂池伤害={百年=0,千年=0,万年=0,十万年=0}

end

function 场景类_奇经神脉:打开(数据)
	if self.可视 then
		for i=1,21 do
			self.资源组[6][i].尝试 = nil
			self.资源组[6][i].技能树 = nil
			self.资源组[6][i].技能 = nil
		end
		self.头像 = nil
		self.选中 = nil
		self.可视 = false
		self.资源组=nil
	else
		self:重新加载资源()
		if  self.x > 全局游戏宽度 then
			self.x = 90+(全局游戏宽度-800)/2
		end
		self.数据 =数据
		if self.数据.门派 == "无" then
			tp.提示:写入("#Y/你还未拜入门派")
			return
		end
		insert(tp.窗口_,self)
	--	table.print(数据)
		--self.头像 = tp.资源:载入("JM.dll","网易WDF动画",ms(self.数据.造型))
		local qj = sk(self.数据.门派)
		local 临时加成={}
		local 临时品质={}
		if self.数据.奇经神脉.学习数量~=nil then
		for n=1,self.数据.奇经神脉.学习数量 do
			qj[n]=self.数据.奇经神脉.记忆位置[n].名称
			if self.数据.奇经神脉.记忆位置[n].加成~=nil then
				临时加成[n]=self.数据.奇经神脉.记忆位置[n].加成
				临时品质[n]=self.数据.奇经神脉.记忆位置[n].品质
			end
		end
		end
		for m=1,21 do
			self.资源组[6][m]:置技能({名称=qj[m]},3)
			if 临时加成[m]~=nil then
				self.资源组[6][m].加成=临时加成[m]
			end
			if 临时品质[m]~=nil then
				self.资源组[6][m].品质=临时品质[m]
			end
		end
		if self.数据.奇经神脉.技能树 ~= nil and type(self.数据.奇经神脉.技能树) ~= "number" then
			for n=1,#self.数据.奇经神脉.技能树 do
				self.资源组[6][self.数据.奇经神脉.技能树[n]].技能树 = true
			end
		end
		self.资源组[6][20].介绍 = ew(self.数据.门派)
		tp.运行时间 = tp.运行时间 + 1
		self.窗口时间 = tp.运行时间
		self.可视 = true
		self.魂池伤害=self:计算魂池数量(self.数据.奇经神脉)
	end
end
function 场景类_奇经神脉:重新加载资源()
	local 资源 = tp.资源
	local 按钮 =tp._按钮
	local 自适应 = tp._自适应
	tp.删除奇经神脉=nil
	self.资源组 = {
		[1] = 自适应.创建(0,1,300,475,3,9),
		[2] = 按钮.创建(自适应.创建(18,4,16,16,4,3),0,0,4,true,true),
		[3] = 按钮.创建(自适应.创建(11,4,72,20,1,3),0,0,4,true,true,"确认加点"),
		[4] = 按钮.创建(自适应.创建(11,4,55,20,1,3),0,0,4,true,true,"取消"),
		[5] = 按钮.创建(自适应.创建(11,4,72,20,1,3),0,0,4,true,true,"重置魂池"),
		[6] = {},
		[7] = 资源:载入('JM.dll',"网易WDF动画",0x22D22D6D),
		[8] = 自适应.创建(5,1,270,419,3,9),
		[9] = 资源:载入('JM.dll',"网易WDF动画",0xECEDD9A8).精灵,

	}
	self.资源组[9]:置区域(0,0,2,395)
	for n=2,5 do
	    self.资源组[n]:绑定窗口_(33)
	end
	for i=1,21 do
		self.资源组[6][i] = tp._技能格子(0,0,n,"奇经神脉")
	end
	local wz = require("gge文字类")
	self.方正字体 = wz.创建(程序目录.."Data/pic/qingyi.ttf",14,false,true,true)
	self.方正字体:置颜色(0xffffffff)
	self.方正字体:置描边颜色(0xff000000)

end
function 场景类_奇经神脉:刷新(数据)
	self:重新加载资源()
		self.头像 = nil
		self.选中 = nil
	  self.数据 =数据
	  tp.删除奇经神脉=nil
	 self.头像 = tp.资源:载入("JM.dll","网易WDF动画",ms(self.数据.造型))
		local qj = sk(self.数据.门派)
		local 临时加成={}
		local 临时品质={}
		if self.数据.奇经神脉.学习数量~=nil then
			for n=1,self.数据.奇经神脉.学习数量 do
				qj[n]=self.数据.奇经神脉.记忆位置[n].名称
				临时加成[n]=self.数据.奇经神脉.记忆位置[n].加成
				临时品质[n]=self.数据.奇经神脉.记忆位置[n].品质
			end
		end
		for m=1,21 do
			self.资源组[6][m]:置技能({名称=qj[m]},3)
			if 临时加成[m]~=nil then
				self.资源组[6][m].加成=临时加成[m]
			end
			if 临时品质[m]~=nil then
				self.资源组[6][m].品质=临时品质[m]
			end
		end
		if self.数据.奇经神脉.技能树 ~= nil and type(self.数据.奇经神脉.技能树) ~= "number" then
			for n=1,#self.数据.奇经神脉.技能树 do
				self.资源组[6][self.数据.奇经神脉.技能树[n]].技能树 = true
			end
		end
		self.资源组[6][20].介绍 = ew(self.数据.门派)
		self.魂池伤害=self:计算魂池数量(self.数据.奇经神脉)
end



function 场景类_奇经神脉:显示(dt,x,y)
	self.焦点 = false
	self.资源组[2]:更新(x,y)
	self.资源组[5]:更新(x,y)
	if self.资源组[2]:事件判断() then
		self:打开()
		return false
	elseif self.资源组[5]:事件判断() then
		tp.窗口.文本栏:载入("#H/重置魂池需要花费500万银子，你是否要重置魂池？：","经脉",true)
	end
	self.资源组[1]:显示(self.x,self.y)
	self.资源组[8]:显示(self.x+14,self.y+30)
	--self.资源组[9]:显示(self.x+255,self.y+42)
	tp.窗口标题背景_:显示(self.x+20+self.资源组[1].宽度/2-90,self.y)
	self.资源组[2]:显示(self.x+280,self.y+3)


	zts1:置颜色(0xFFFFFFFF):显示(self.x+120,self.y+3,"魂 环 池")

	--self.资源组[3]:显示(self.x+350,self.y+415,true,1)
	--self.资源组[4]:显示(self.x+445,self.y+415,true,1)

	--zts1:置颜色(0xFFFFFFFF):显示(self.x+282,self.y+3,"斗罗魂环")
	self.资源组[5]:显示(self.x+220,self.y+450,true,1)
--	self.头像:置颜色(1342177280)
	--self.头像:显示(self.x+((820-self.头像.宽度)/2),self.y+40)
	local xx = 0
	local yy = 1
	self.资源组[7]:更新(dt)
	for n=1,21 do
		self.资源组[6][n]:置坐标(self.x + xx * 75 + 35,self.y + yy * 55 - 5)
		if self.数据.奇经神脉[self.资源组[6][n].技能.名称] == nil  then
			self.资源组[6][n].技能.模型:灰度级()
		end
		self.资源组[6][n]:显示(x,y,self.鼠标)
		-- if self.资源组[6][n].技能树 ~= nil then
		-- 	self.资源组[7]:显示(self.x + xx * 75 + 25,self.y + yy * 55 - 14)
		-- end
		if self.资源组[6][n].技能 ~= nil and self.资源组[6][n].焦点 then
			if self.资源组[6][n].加成~=nil then
			tp.提示:魂环技能(x,y,self.资源组[6][n].技能,self.资源组[6][n].加成,self.资源组[6][n].品质)
			   if 引擎.鼠标弹起(0) and self.鼠标 and not tp.窗口.文本栏.可视 then
			   	tp.删除奇经神脉=n
				   tp.窗口.文本栏:载入("#H/拔出魂环#Y/需要花费#R/".."一亿银子".."#W/,你确定要拔出吗?","删除奇经神脉",true)
		   	end
	  	else
			tp.提示:技能(x,y,self.资源组[6][n].技能)
	 	end
			-- if mouseb(0) and self.资源组[6][n].技能树 ~= nil and self.数据.奇经神脉[self.资源组[6][n].技能.名称] == nil then
			-- 	self.选中 = n
			-- 	self.资源组[6][n].尝试 = true
			-- 	local qj = sk(self.数据.门派)
			-- 	for m=1,#qj do
			-- 		self.资源组[6][m]:置技能({名称=qj[m]},3)
			-- 		self.资源组[6][m].技能树 = nil
			-- 	end
			-- end
		end
		xx = xx + 1
		if xx >= 3 then
			xx = 0
			yy = yy + 1
		end
	end

	-- self.方正字体:显示(self.x+265,self.y+392,"百年魂环:"..self.魂池伤害.百年)
	-- self.方正字体:显示(self.x+265+119,self.y+392,"千年魂环:"..self.魂池伤害.千年)
	-- self.方正字体:显示(self.x+265,self.y+412,"万年魂环:"..self.魂池伤害.万年)
	-- self.方正字体:显示(self.x+265+119,self.y+412,"十万魂环:"..self.魂池伤害.十万年)
--	print(左右)
	--zts:显示(self.x+515,self.y+392,"可换乾元丹")
	--zts:置颜色(-256)
--	zts:显示(self.x+335,self.y+391.8,format("乾元丹:%d+%d",self.数据.奇经神脉.乾元丹,self.数据.奇经神脉.附加乾元丹))
	--zts:显示(self.x+490,self.y+391.8,format(":%d",self.数据.奇经神脉.剩余乾元丹))
	--zts:显示(self.x+583,self.y+391.8,format(":%d",self.数据.奇经神脉.可换乾元丹))
end


function 场景类_奇经神脉:计算魂池数量(数据)
  -- local 魂环数量={百年=0,千年=0,万年=0,十万年=0}
  -- for n=1,#数据.记忆位置 do
  --     if 数据.记忆位置[n]=="百年魂环" then
  --       魂环数量.百年=魂环数量.百年+1
  --   elseif 数据.记忆位置[n]=="千年魂环" then
  --       魂环数量.千年=魂环数量.千年+1
  --   elseif 数据.记忆位置[n]=="万年魂环" then
  --       魂环数量.万年=魂环数量.万年+1
  --   elseif 数据.记忆位置[n]=="十万年魂环" then
  --       魂环数量.十万年= 魂环数量.十万年+1
  --   end
  -- end
  -- local 魂环伤害={百年=魂环数量.百年*100,千年=魂环数量.千年*500,万年=魂环数量.万年*2000,十万年=魂环数量.十万年*5000}
  -- return 魂环伤害
end

function 场景类_奇经神脉:技能树(a)
	if a == 1 or a == 4 or a == 7 or a == 10 or a == 13 or a == 16 then
		if a == 16 then
			return {a+3}
		else
			return {a+3,a+4}
		end
	elseif a == 2 or a == 5 or a == 8 or a == 11 or a == 14 or a == 17 then
		if a == 17 then
			return {a+2,a+4}
		else
			return {a+2,a+3,a+4}
		end
	elseif a == 3 or a == 6 or a == 9 or a == 12 or a == 15 or a == 18 then
		if a == 18 then
			return {a+3}
		else
			return {a+2,a+3}
		end
	end
end



return 场景类_奇经神脉